from django.contrib import admin

# Register your models here.
from mptt.admin import MPTTModelAdmin

from assistinfo.models import *


@admin.register(CustomCatagery)
class CustomCatageryAdmin(admin.ModelAdmin):
    list_display = ['category']
    search_fields = ['category']


@admin.register(SupplierCatagery)
class SupplierCatageryAdmin(admin.ModelAdmin):
    list_display = ['category']
    search_fields = ['category']


@admin.register(CommodityCatagery)
class CommodityCatageryAdmin(MPTTModelAdmin):
    list_display = ['category']
    search_fields = ['category']

    def get_parent(self, obj):
        return obj.parent.category if obj.parent else '-'

    get_parent.short_description = u'上级类别'
    get_parent.admin_order_field = 'parent'

@admin.register(OutComeCatagery)
class OutComeCatageryAdmin(admin.ModelAdmin):
    list_display = ['category']
    search_fields = ['category']


@admin.register(CustomLevel)
class CustomLevelAdmin(admin.ModelAdmin):
    list_display = ['level']
    search_fields = ['level']


@admin.register(InComeCatagery)
class InComeCatageryAdmin(admin.ModelAdmin):
    list_display = ['category']
    search_fields = ['category']


@admin.register(CountUnit)
class CountUnitAdmin(admin.ModelAdmin):
    list_display = ['unit']
    search_fields = ['unit']


@admin.register(SettlementWay)
class SettlementWayAdmin(admin.ModelAdmin):
    list_display = ['settlement']
    search_fields = ['settlement']
